package com.atguigu.gmall.activity.service.impl;

import com.atguigu.gmall.activity.service.ActivityService;
import com.atguigu.gmall.common.constant.RedisConst;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private RedisTemplate redisTemplate;
    //获取整合Hash所有的集合
    @Override
    public List<SeckillGoods> getSeckillList() {
        return
                redisTemplate.opsForHash().values(RedisConst.SECKILL_GOODS);
    }

    @Override
    public SeckillGoods getSecKillGoodsById(Long skuId) {
        return (SeckillGoods) redisTemplate.opsForHash().
                get(RedisConst.SECKILL_GOODS,skuId.toString());
    }
}
